//
//  GFLikeFoodTableViewCell.m
//  GoodFood
//
//  Created by dllo on 15/11/3.
//  Copyright © 2015年 荣伟峰. All rights reserved.
//

#import "GFLikeFoodTableViewCell.h"

@interface GFLikeFoodTableViewCell ()

@property (nonatomic, strong) UIImageView *userImage;
@property (nonatomic, strong) UILabel *userNameLabel;
@property (nonatomic, strong) UILabel *likeLabel;

@end

@implementation GFLikeFoodTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.userImage = [[UIImageView alloc] init];
        [self.contentView addSubview:self.userImage];
        
        self.userNameLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.userNameLabel];
        
        self.likeLabel = [[UILabel alloc] init];
        self.likeLabel.font = [UIFont systemFontOfSize:13];
        self.likeLabel.textColor = [UIColor colorWithRed:0.632 green:0.654 blue:0.659 alpha:1.000];
        [self.contentView addSubview:self.likeLabel];
    }
    return self;
}

-(void)layoutSubviews {
    
    [super layoutSubviews];
    
    self.userImage.frame = CGRectMake(10, 10, ScreenWidth / 10, ScreenWidth / 10);
    
    self.userNameLabel.frame = CGRectMake(10 + ScreenWidth / 10 + 10, 10, ScreenWidth - (10 + ScreenWidth / 10 + 10), ScreenWidth / 20);

    self.likeLabel.frame = CGRectMake(ScreenWidth / 10 + 20, 10 + ScreenWidth / 20, ScreenWidth - (ScreenWidth / 10 + 20), ScreenWidth / 20);
    
}

-(void)setTempDic:(NSDictionary *)tempDic {
    
    if (_tempDic != tempDic) {
        _tempDic = tempDic;
    }
    [self.userImage setImageWithURL:[NSURL URLWithString:tempDic[@"user_image"]] placeholderImage:[UIImage imageNamed:@"category_1"]];
    if ([tempDic[@"tobeloved"] integerValue] == 0) {
        self.likeLabel.text = nil;
    } else {
        
        self.likeLabel.text = [NSString stringWithFormat:@"Ta的分享被%@人喜欢过", tempDic[@"tobeloved"]];
        
    }
    self.userNameLabel.text = tempDic[@"user_name"];
    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
